<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  props: {
    modelValue: { type: Number, required: true },
    maxlength: { type: Number, default: 100 },
    showLimit: { type: Boolean, default: true },
    background: { type: String, default: "#ffffff" },
  },
});
</script>

<template>
  <view class="form-word" :style="{ background }">
    <slot />
    <view class="form-word-num" v-show="showLimit">
      {{ modelValue > maxlength ? maxlength : modelValue }}/{{ maxlength }}
    </view>
  </view>
</template>

<style lang="scss">
.form-word {
  position: relative;
  padding-bottom: 20rpx;

  .form-word-num {
    position: absolute;
    right: 30rpx;
    bottom: 12rpx;
    font-size: 26rpx;
    color: #999999;
    // line-height: 46rpx;
  }
}
</style>